# -*- coding: UTF-8 -*-
# __author__ = 'Sengo'
import math
import numpy as np


def vertex_multiply(a, b):
    """a*b cross multiply向量叉乘"""
    ax = a[0]
    ay = a[1]
    az = a[2]
    bx = b[0]
    by = b[1]
    bz = b[2]
    cx = ay*bz - az*by
    cy = az*bx - ax*bz
    cz = ax*by - ay*bx
    return [cx, cy, cz]


def vertex_dot_multiply(a, b):
    """向量点乘"""
    ax = a[0]
    ay = a[1]
    az = a[2]
    bx = b[0]
    by = b[1]
    bz = b[2]
    return ax*bx + ay*by + az*bz


def unit_vector(a, b):
    """两个点a, b求单位向量ab"""
    dist = (a[0]-b[0])(a[0]-b[0]) + (a[1]-b[1])(a[1]-b[1]) + (a[2]-b[2])(a[2]-b[2])
    dist = math.sqrt(dist)
    return (b[0]-a[0])*1.0/dist, (b[1]-a[1])*1.0/dist, (b[2]-a[2])*1.0/dist


def vector_add(a, b):
    """向量相加， input:list"""
    return np.array(a) + np.array(b)